package com.itHsuSE.demo8;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;

/**
 * @author Hsu琛君珩
 * @ClassName:Test14
 * @date 2023-12-19
 * @apiNote
 * @Version: v1.0
 */

public class Test14 {
    public static void main(String[] args) {
        JFrame jf = new JFrame("监听时间测试");
        jf.setLayout((new FlowLayout(FlowLayout.CENTER)));
        jf.setBounds(400, 300, 300, 400);

        JTextArea area=new JTextArea(20,10);
        JButton button=new JButton("hi");
        area.setLineWrap(true);//自动换行
        jf.add(area);
        jf.add(button);

        button.addActionListener((new AbstractAction() {
            @Override
            public void actionPerformed(ActionEvent e) {
                area.append("hello");
                //如果用area.setText("hello");会覆盖掉
            }
        }));

        jf.setVisible(true);
        jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }
}
